/*
 * DInterno.java
 *
 * Created on 21 de septiembre de 2006, 07:50 AM
 */

package ig.formato.gui.app;

import javax.swing.JDesktopPane;

/**
 *
 * @author  jsanchez
 */
public class DInterno extends javax.swing.JInternalFrame {
    
    /** Creates new form DInterno */
    public DInterno() {
        super("Acrobat Reader[Acrobat.Viewer]",true,true,true,true);
        initComponents();
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {

        addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentMoved(java.awt.event.ComponentEvent evt) {
                formComponentMoved(evt);
            }
            public void componentResized(java.awt.event.ComponentEvent evt) {
                formComponentResized(evt);
            }
        });
        addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                formFocusLost(evt);
            }
        });
        addInternalFrameListener(new javax.swing.event.InternalFrameListener() {
            public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) {
                formInternalFrameDeactivated(evt);
            }
            public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
            }
        });

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 394, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 274, Short.MAX_VALUE)
        );
        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void formInternalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameDeactivated
        try {
            if(this.getTitle().startsWith("Acrobat Reader"))
                this.setIcon(true);
        } catch (Exception e) {}        
    }//GEN-LAST:event_formInternalFrameDeactivated

    private void formFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_formFocusLost

    }//GEN-LAST:event_formFocusLost

    private void formComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentResized
//        System.out.println("otro mas");
        //this.setDefaultCloseOperation(this.DO_NOTHING_ON_CLOSE);        
    }//GEN-LAST:event_formComponentResized

    private void formComponentMoved(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentMoved
        Double x=this.getLocation().getX();
        Double y=this.getLocation().getY();
        if(x<0)
            this.setLocation(0,y.intValue());
        else if(y<0)
            this.setLocation(x.intValue(),0);
//        else if(y>getParent().getBounds().getWidth()-this.getBounds().getWidth());
//            this.setLocation(x.intValue(),50);
//        System.out.println("***");
//        System.out.println("x:"+x);
//        System.out.println("y:"+y);
//        System.out.println("H:"+getParent().getBounds().getHeight());
//        System.out.println("W:"+getParent().getBounds().getWidth());
        ((JDesktopPane)getParent()).updateUI();
    }//GEN-LAST:event_formComponentMoved
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
    
}
